Arduino and Raspberry Pi Sensor Projects for the Evil Genius by Robert Chin

Arduino and Raspberry Pi Sensor Projects for the Evil Genius by Robert Chin

Author:Robert Chin
Language: eng
Format: epub, pdf
Publisher: McGraw-Hill Education
Published: 2017-08-21T04:00:00+00:00


Setting Up the Hardware

To build this hands-on example project, you will need to:

Connect the GND pin on the flame sensor to a GND pin of the Raspberry Pi.

Connect the VCC pin on the flame sensor to a 3.3-V pin of the Raspberry Pi.

Connect the DOUT pin on the flame sensor to pin 14 of the Raspberry Pi (Figure 5-12).

Figure 5-12

Raspberry Pi flame sensor test.

Setting Up the Software

The program for this example project tests the flame sensor by:

1. Importing the RPi.GPIO library.

2. Assigning pin 14 of the Raspberry Pi to the output pin on the flame sensor, which is represented by the FlameOutPin variable.

3. Initializing RawValue, which is the variable that reads data from the flame sensor to 0.

4. Setting the general-purpose input-output (GPIO) pin numbering system to BCM mode.

5. Setting the FlameOutPin as an input pin so that data from the flame sensor can be read.

6. Printing a message to the terminal indicating that the program has started running.

7. Doing the following until a keyboard interrupt has been detected:

a. Read the value from the flame sensor output pin.

b. If the value read is 0, then a flame has been detected, so print out a message to the terminal indicating that a flame was found.

c. If the value read is not 0, then no flame is detected, so print out a message to the terminal indicating that no flame was found.

8. Print out the raw value read from the flame sensor in step 1.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.